package com.beone.admin.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.base.SuperServiceImpl;
import com.beone.admin.entity.TaskTemplateDetail;
import com.beone.admin.mapper.TaskTemplateDetailMapper;
import com.beone.admin.service.TaskTemplateDetailService;
import com.beone.admin.utils.PaginationGatagridTable;
import com.beone.admin.utils.ServiceUtils;

/**
 * @Title 排班模板明细 服务实现类
 * @Author 秦波
 * @Version 1.0 on 2019-06-01
 * @Copyright 贝旺科权
 */
@Service
public class TaskTemplateDetailServiceImpl extends SuperServiceImpl<TaskTemplateDetailMapper, TaskTemplateDetail>
    implements TaskTemplateDetailService {

    /**
     * 分页显示排班模板明细列表
     * 
     * @param entity
     * @param currPage
     *            当前页码
     * @param pageSize
     *            每页显示记录数
     * @return
     */
    @Override
    public PaginationGatagridTable getTaskTemplateDetailPagination(TaskTemplateDetail entity, int currPage,
        int pageSize) {
        EntityWrapper<TaskTemplateDetail> ew = new EntityWrapper<>();
        Page<TaskTemplateDetail> page = new Page<>(currPage, pageSize);
        List<TaskTemplateDetail> rows = baseMapper.selectPage(page, ew);
        return ServiceUtils.createGatagridTableJson(page, rows);
    }

    @Override
    public List<TaskTemplateDetail> getDetailListByTemplatId(Integer templateId) {
        EntityWrapper<TaskTemplateDetail> ew = new EntityWrapper<>();
        ew.eq("template_id", templateId);
        ew.orderBy("order_no");
        return baseMapper.selectList(ew);
    }
}
